package com.hao.demo.springcloud.client.provider;

import com.hao.demo.springcloud.client.provider.dto.DemoDTO;
import com.hao.demo.springcloud.client.provider.impl.DemoProviderImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotNull;

@FeignClient(name = "server-springcloud", fallback = DemoProviderImpl.class)
public interface DemoProvider {

    String prefix = "/server/demo/";

    @GetMapping(prefix + "queryByName")
    String queryByName(@RequestParam("name") @NotNull(message = "名称不能为空") String name);

    @PostMapping(prefix + "createDemo")
    String createDemo(@RequestBody DemoDTO demoDTO);

    @GetMapping(prefix + "queryDemoDTO")
    String queryDemoDTO(@SpringQueryMap DemoDTO demoDTO);
}
